<?php

namespace App\Jobs;

use App\Http\Service\OSSClient\QiniuyunOSSClientService;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;


class liveRecordFileDealWithTask implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public array $config;
    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($config)
    {
        $this->config = $config;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        Log::info('start deal with live record file upload task: ' . $this->config['filePath']);
        $xmlConfig = [
            "key" => trim($this->config['key'], ".flv") . ".xml",
            "filePath" =>  trim($this->config['filePath'], ".flv") . ".xml"
        ];
        $clientService = new QiniuyunOSSClientService();
        $clientService->uploadFile($xmlConfig['key'],$xmlConfig['filePath'], true);
        $clientService->uploadFile($this->config['key'],$this->config['filePath'], true);
    }
}
